#ifndef SHADOWMAP_SAMPLE_H
#define SHADOWMAP_SAMPLE_H
#include "SampleBase.h"
#include "glslprogram.h"
#include "plane.h"
#include "objmesh.h"
#include "frustum.h"
namespace ShaderLab {
	class ShadowMapSample : public SampleBase {
	public:
		ShadowMapSample();
		~ShadowMapSample();

		void Init();
		void Update(float time);
		void Render();
		void Imgui();
		void ShutDown();
	private:
		GLSLProgram prog, solidProg;
		GLuint shadowFBO, pass1Index, pass2Index;
		std::unique_ptr<Plane> plane;
		std::unique_ptr<ObjMesh> mesh;
		int shadowMapWidth, shadowMapHeight;
		GLuint depthTex;
		glm::mat4 lightPV, shadowBias;
		Frustum lightFrustum;
		glm::mat4 model, view, projection;
		glm::vec3 lightPos;
		GLuint depthBufferHandle;
	private:
		void UpdateMat();
		void CreateShader();
		void FBO();
		void Scene();
		void DepthBuffer();
	};
}
#endif // !TEMPLATE_SAMPLE_H
